export let login = state => state.login
export let getClientMenu = state => state.session.clientMenu
import { getCache } from '@/utils/m7Utils.js'
export const agents = state => {
  // let dicMap = state.session.dicMap || {}
  let agents = getCache('agents') || []
  let dicMapGetterVersion = state.dicMapGetterVersion
  console.log(dicMapGetterVersion)
  if (agents.length === 0) return null
  let AgentsObj = {}
  if (agents.length > 0) {
    agents.forEach(item => {
      AgentsObj[item._id] = JSON.parse(JSON.stringify(item))
    })
  }
  return AgentsObj
}
export const filterStopAgents = state => {
  let agents = getCache('agents') || []
  console.log(agents, 'agents6666')
  if (agents.length === 0) return null
  let stopAgents = []
  if (agents.length > 0) {
    stopAgents = agents.filter(item => {
      return item.status === 'enable'
    })
  }
  return stopAgents
}
export const userHidden = state => {
  let userHidden = getCache('userHidden') || []
  let userHiddenDoc = (userHidden[0] && userHidden[0].userHiddenDoc) || 'no'
  return userHiddenDoc
}
export const accountName = state => {
  let accountName = ''
  if (state.session && state.session.account && (state.session.user.isAdmin && state.session.user.isAdmin === true)) {
    if (state.session.account.companyName) {
      accountName = ' - ' + state.session.account.companyName
    } else {
      accountName = ' - ' + state.session.account.name
    }
  } else {
    accountName = ''
  }
  return accountName
}
export const custCategorys = state => {
  // let dicMap = state.session.dicMap || {}
  let dicMapGetterVersion = state.dicMapGetterVersion
  console.log(dicMapGetterVersion)
  let custCategorys = getCache('custCategorys') || []
  if (custCategorys.length === 0) return null
  let custCategorysObj = {}
  if (custCategorys.length > 0) {
    custCategorys.forEach(item => {
      custCategorysObj[item._id] = JSON.parse(JSON.stringify(item))
    })
  }
  return custCategorysObj
}

// export const exportFromFront = state => {
//   return (
//     state.xlsxExportMode === 'Front' ||
//     state.xlsxExportMode === 'Both'
//   )
// }

export const exportFromEnd = state => {
  return (
    state.xlsxExportMode === 'End' ||
    state.xlsxExportMode === 'Both'
  )
}

export const isEcommerce = state => {
  return (
    state.session.account && state.session.account.platform === 'ds'
  )
}
